﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System;

public class HeadController : MonoBehaviour {
    private Image image;
    private GameObject hero;
    private Animator hero_animator;
    private bool die;
    // Use this for initialization
	void Start () {
        image = this.GetComponent<Image>();
        die = false;
        hero = GameObject.Find("Garrosh");
        hero_animator = hero.GetComponent<Animator>();
    }

    // Update is called once per frame
    //void OnMouseDown() {

    //    Debug.Log("haahaha");
    //}


    void Update () {
        if (hero_animator.GetCurrentAnimatorStateInfo(0).IsName("ga_attacked"))
        {
            image.sprite = Resources.Load("image/ga_head_cry", typeof(Sprite)) as Sprite;
        }
        else if (die||hero_animator.GetCurrentAnimatorStateInfo(0).IsName("ga_die")) {
            die = true;
            image.sprite = Resources.Load("image/ga_head_die", typeof(Sprite)) as Sprite;
        }
        else
        {
            image.sprite = Resources.Load("image/ga_head", typeof(Sprite)) as Sprite;
        }
    }


}
